package leaveSystem.utility;

import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

public class DateUtility {
	public static final String DATE_FORMAT = "d-MM-yyyy";
	public static final String TIME_FORMAT = "d-MM-yyyy H:mm";
	private static DateFormat tf = new SimpleDateFormat(TIME_FORMAT);
	private static DateFormat df = new SimpleDateFormat(DATE_FORMAT);
	private Date date;
	
	public Date getDate(){
		date=new Date();
		Calendar cal=Calendar.getInstance();
		cal.setTime(date);
		return cal.getTime();
	}
	
	public java.sql.Date ConvertUtilToSql(String calDate) throws Exception{
		java.sql.Date sqlDate = new java.sql.Date( df.parse(calDate).getTime());
	
		return sqlDate;
	}
	public java.sql.Date ConvertUtilToSql(java.util.Date calDate) throws Exception{
		java.sql.Date sqlDate = new java.sql.Date(calDate.getTime());
		return sqlDate;
	}
	public java.util.Date ConvertStringToDate(String strDate){
		try {
			Date d = df.parse(strDate);
			return d;
		} catch (ParseException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return null;
	}
	

	/*
	public java.util.Calendar ConvertSqlToUtil(java.sql.Date date){
		return null;
	}
	*/
}
